package com.pl.getaway.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;

import com.hookgetaway.R;
import com.hookgetaway.utils.GetAwayApplication;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/* loaded from: classes3.dex */
public class ReplaceNameTextView extends AppCompatTextView {
    public static final Set<String> b;
    public Boolean a;

    static {
        HashSet hashSet = new HashSet();
        b = hashSet;
        hashSet.add("不做手机控公众号");
        hashSet.add("不做手机控APP");
    }

    public ReplaceNameTextView(Context context) {
        super(context);
        this.a = Boolean.TRUE;
        a(context, null);
    }

    public static String b(String str) {
        Iterator<String> it = b.iterator();
        while (it.hasNext()) {
            if (str.contains(it.next())) {
                return str;
            }
        }
        if (str.contains("不做手机控")) {
            str = str.replaceAll("不做手机控", GetAwayApplication.getAppContext().getResources().getString(R.string.app_name));
        }
        return str.contains("手机控") ? str.replaceAll("手机控", GetAwayApplication.getAppContext().getResources().getString(R.string.app_name_short)) : str;
    }

    public void a(Context context, @Nullable AttributeSet attributeSet) {
        TypedArray obtainStyledAttributes = getContext().obtainStyledAttributes(attributeSet, R.styleable.ReplaceNameTextView);
        this.a = Boolean.valueOf(obtainStyledAttributes.getBoolean(0, true));
        obtainStyledAttributes.recycle();
    }

    @Override // android.widget.TextView
    public void setText(CharSequence charSequence, TextView.BufferType bufferType) {
        Boolean bool = this.a;
        if (bool != null && !bool.booleanValue()) {
            super.setText(charSequence, bufferType);
        } else {
            if (true) {
                super.setText(charSequence, bufferType);
                return;
            }
            if (charSequence instanceof String) {
                charSequence = b(charSequence.toString());
            }
            super.setText(charSequence, bufferType);
        }
    }

    public ReplaceNameTextView(Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
        this.a = Boolean.TRUE;
        a(context, attributeSet);
    }

    public ReplaceNameTextView(Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.a = Boolean.TRUE;
        a(context, attributeSet);
    }
}